{extend name="base" /} {block name="body"}
<div class="layui-body">
	<div class="navbar">
		<a><cite>新闻管理</cite></a>&nbsp;<span class="layui-box">&gt;</span>
		<a href=""><cite>编辑新闻</cite></a>
	</div>
	<!--tab标签-->
	<div class="layui-tab layui-tab-card margin10">
		<ul class="layui-tab-title">
			<li class="layui-this">编辑新闻</li>
		</ul>
		<div class="layui-tab-content">
			<form class="layui-form form-container layui-form-pane" action="" method="post">
				<div class="layui-form-item">
					<label class="layui-form-label">标题</label>
					<div class="layui-input-block">
						<input type="text" name="title" value="{$news[0]['title']}" lay-verify="required" placeholder="请输入标题" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">类型</label>
					<div class="layui-input-block">
						<select name='cart_id' lay-filter="cart_id">
							<option value=''>请选择</option>
							{foreach name="$result" item="val"}
							<option value="{$val['id']}">{$val.name}</option>
							{/foreach}
						</select>

						<select id='cart_id1' name='cart_id1' lay-filter="cart_id1">
							<option value=''>请选择</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">内容</label>
					<div class="layui-input-block">
						<input type="text" name="content" value="{$news[0]['content']}" lay-verify="required" placeholder="请填写内容" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">点击量</label>
					<div class="layui-input-block">
						<input type="text" name="clock" value="{$news[0]['clock']}" lay-verify="required" placeholder="请输入点击量" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">封面图</label>
					<div class="layui-input-block" style="padding-left: 10px;">
						<div class="layui-upload">
							<button type="button" class="layui-btn" id="image">上传图片</button>
							<div class="layui-upload-list">
								<img class="layui-upload-img" src="{$news[0]['thumb']}" style="width: 150px;height: 150px;" id="demo1">
								<p id="demoText"></p>
							</div>
						</div>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">商品详情</label>
					<div class="layui-input-block">
						<textarea placeholder="请输入内容" class="layui-textarea" name="editorValue" id='containe' value="{$news[0]['editorValue']}">{$news[0]['editorValue']}</textarea>
					</div>
				</div>
				<input type="hidden" name="thumb" id="thumb" value="{$news[0]['thumb']}" />
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" lay-submit lay-filter=""><i class="fa fa-save"></i> 保存</button>
						<a href="{:url('index')}" class="layui-btn layui-btn-primary"><i class="fa fa-arrow-left"></i> 返回</a>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<link rel="stylesheet" src="/public/static/layui/css/layui.css" media="all">
<script src="/public/static/layui/layui.js" charset="utf-8"></script>
<script src="/public/ueditor/ueditor.all.js" charset="utf-8"></script>
<script id="containe" name="content" type="text/plain">
	这里写你的初始化内容
</script>
配置文件
<script type="text/javascript" src="/PUBLIC/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/PUBLIC/ueditor/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
	var ue = UE.getEditor('containe');
</script>--> {/block} {block name="js"}
<script>
	layui.use('form', function() {
		var form = layui.form;
		form.on('select(cart_id)', function(data) {
			$('#cart_id1').html('');
			var html = '';
			$.ajax({
				type: 'get',
				url: "{:url('news_list')}",
				data: {
					cart_id: data.value
				},
				dataType: 'json',
				success: function(res) {
					$.each(res, function(index, item) {
						//	select.options.add(new Option(item[i]));
						html += "<option value='" + item.id + "'>" + item.name + "</option>";
						 console.log(html);
						$("#cart_id1").html(html);
						form.render('select');
					});

				},

				error: function() {
					layer.msg('网络连接失败', {
						icon: 5
					});
				}

			});
		});

		//各种基于事件的操作，下面会有进一步介绍
	});
		layui.use('upload', function() {
		var upload = layui.upload,
		jq = layui.jquery;
		upload.render({
			url: '{:url("upload")}',
			elem: '#image',
			ext: 'jpg|png|gif',
			area: ['500', '500px'],
			before: function(input) {
				
			},
			done: function(res) {
				if(res.code==1){
					$("#demo1").attr('src',res.src);
					$("#thumb").val(res.src);
				}
			}
		});

})
</script>
{/block}